<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmls="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">  
<style type="text/css">   
</style>  
<link rel="stylesheet" type="text/css" href="../newmap.css"> 
<!--[if lte IE 10]><link rel="stylesheet" href="../newmap.ie.css" /><![endif]--> 
<script type="text/javascript" src="../NewMap.js"></script>
<script type="text/javascript" src="print.js"></script> 
<script type="text/javascript" src="../PlotUtils.js"></script> 
<script type="text/javascript" src="../NPlotSymbols.js"></script>   
<script type="text/javascript">  
//定义地图和要素为全局变量  
var m;  var layer;
function mapInit () {  
	m = new NMap("map");
	
	var lyrOptions = {
		tileSize: new NXY(256, 256),
		tileOrigin: new NXY(0,0),
		resolutions: [0.087890625, 0.0439453125,0.02197265625,0.010986328125],
		format: "image/png",
		units: "dd",
		projection: "EPSG:4326",
		maxExtent: new NBounds(67.855808,5.373855,140.676983,54.502712),
		//serverResolutions: {"0":0.087890625,'1':0.0439453125},  
		layer:"sample2",  
		style:"Default",   
		tileMatrixSet:"TileMatrixSet_0"  
	};
	 //NTileLayer类实例化
	var layer = new NWMTSLayer("sample2", "http://127.0.0.1:8099/newmap/ogc/samples/chinatile2/wmts", lyrOptions);   
	//m.addLayer(layer);
	
	var lyrOptions1 = {
		tileSize: new NXY(256, 256),
		tileOrigin: new NXY(-180, 90),
		resolutions: [0.087890625, 0.0439453125, 0.02197265625, 0.010986328125],
		format: "image/png",
		units: "dd",
		isBasicLayer: true,
		projection: "EPSG:4326",
		maxExtent: new NBounds(73.446960000000004,3.4084772999999999,135.08583068847656,53.557926177978516)
	};
	var layer1 = new NMapServerLayer("china", "http://127.0.0.1:8099/newmap/rest/services/samples/china/MapServer/map", lyrOptions1,{LAYERS:'省级行政界面'}); 
	m.addLayer(layer1);
	
	var lyrOptions2 = {
		units: "dd",
		isBasicLayer: 'false',
		visible:'false',
		projection: "EPSG:4326",
		maxExtent: new NBounds(73.446960000000004,3.4084772999999999,135.08583068847656,53.557926177978516)
	};
	var layer2 = new NWMSLayer ("china1", "http://127.0.0.1:8099/newmap/ogc/samples/china/wms", lyrOptions2,{LAYERS:'主要铁路',TRANSPARENT:true}); 
	layer2.setVisible('true');//叠加wms一定要设置isBasicLayer为false
	m.addLayer(layer2);
	
	m.setMode("dragzoom");
	m.addControl(new NPanZoomBarControl());
    m.addControl(new NPositionControl());
    m.addControl(new NScaleControl());	
};

function printfun(){
	document.getElementById("printmap").style.display=""; 
	var layout=new NPageLayout("printmap",m,{printServer:"http://127.0.0.1:8099/newmap/rest/services/utilities/PrintTask/ProcessingServer/print"});
	//layout.proxy="http://127.0.0.1:8099/newmap/rest/proxy.lua?url=";
	layout.on("printWindowClose",closeFun);
	layout.on("printResult",result);
};
function closeFun(obj){
	document.getElementById(obj.id).style.display="none"; 
};
function result(obj){
	document.getElementById("resultimage").src=obj.image;
};

function setmode(value){
	m.setMode(value);
}

function clearmap(){
	m.clearOverlays();
}
</script>  
</head>  
<body onload="mapInit();">                    <!--窗口生成时调用函数-->  
    <div style="height:700px;width:1600px;position:absolute;">
		<div id="map" style="height:100%;width:90%;border-style:groove;"></div>
	</div>
	<div id="printmap"  style="height:700px;width:1400px;display:none;left:80px;top:10px;border:1px solid gray;z-index:99"></div>
	
	<div style="height:50px;position:absolute;top:720px;">
		<input type="button" value="打印" onclick="printfun()" style="margin-top:20px;font-size:20px;font-family:Microsoft YaHei;">
		<input type="button" value="关闭" onclick="colosefun()" style="margin-top:20px;font-size:20px;font-family:Microsoft YaHei;">
		<input type="button" value="画点" onclick="setmode('drawPoint')">
		<input type="button" value="画线" onclick="setmode('drawline')">
		<input type="button" value="画面" onclick="setmode('drawpolygon')">
		<input type="button" value="画圆" onclick="setmode('drawcircle')">
		<input type="button" value="矩形" onclick="setmode('drawrect')">
		<input type="button" value="扇形" onclick="setmode('drawsector')">
		<input type="button" value="marker" onclick="setmode('drawmarker')">
		<input type="button" value="拖拽" onclick="setmode('dragzoom')">
		<input type="button" value="测线" onclick="setmode('measurelength')">
		<input type="button" value="测面" onclick="setmode('measurearea')">
		<input type="button" value="清除" onclick="clearmap()">
		<img id="resultimage" />
		 <canvas id="canvas"  width="877" height="620">
		</canvas>
	</div>
</body>  